Skip to content

Webp and animated media - #68

Merged
jdub233 merged 7 commits into
mainfrom
webp-and-animated
Aug 6, 2026
Merged

Webp and animated media#68
jdub233 merged 7 commits into
mainfrom
webp-and-animated

Conversation

@jdub233

@jdub233 jdub233 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Adds support for resizing animated media in addition to single images. Also adds support for resizing WebP assets.

This change essentially enables the animation processor for all resizes. Testing locally and on the dev stack indicates that still frame processing time is not affected by leaving the animation flag on.

It also adds a try/catch block to detect animated media that exceeds the maximum sharp processing limit. More information is available in the repo wiki, including limitations on what sizes can be processed and what sizes are likely to fail because they are too big.

I've run this in a dev instance of the lambda stack (wordpress-protected-s3-dev in bu-cc nonprod) with a buwp-local container front end and testing shows it to be robust. All unit tests are passing.

Addresses #66 and #67

Merging activates the deploy pipeline and will deploy to prod.

Changes:

  • Extend size-suffix URL matching and original-path reconstruction to include .webp.
  • Update sharp invocation to enable animated frame processing ({ animated: true }).
  • Add a unit test covering WebP original lookup and resize flow.

jdub233 added 4 commits July 30, 2026 14:50
It should not affect single frame files, and will process multi-frame media.
But adding it to this code change for cleanup.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for resizing WebP assets and preserves animated frames when processing animated image formats during on-demand object generation.

Changes:

  • Extend size-suffix URL matching and original-path reconstruction to include .webp.
  • Update sharp invocation to enable animated frame processing ({ animated: true }).
  • Add a unit test covering WebP original lookup and resize flow.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/getOrCreateObject/resizeAndSave.js Enables animated frame handling in sharp and removes the unused getOriginalS3Key export.
src/getOrCreateObject/getOrCreateObject.js Adds .webp to size-suffix detection and original-path reconstruction logic.
src/getOrCreateObject/getOrCreateObject.test.js Adds a WebP fixture/mocked object and a test covering WebP resize behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Large or animated images can exceed sharp's pixel limit, leading to resize failures. This change catches the `exceeds pixel limit` error and serves the original, unscaled image instead of failing the request. Any other sharp errors are still rethrown. Comprehensive unit tests verify this graceful degradation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

}

// This image can't be resized, so serve the original unscaled for this request.
// Nothing is saved to S3, because there is no resized image to save.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 This is a great fallback!

@jdub233
jdub233 merged commit 60ad526 into main Aug 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants